{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compute Error Between S Parameter Matrices" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "import skrf as rf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ns = rf.networkSet.NetworkSet.from_zip(\"LFCN-2352+_S2P.zip\")\n", "ns.plot_s_db()\n", "plt.legend(loc=\"lower center\", ncols=2, fontsize=\"x-small\")\n", "plt.grid()\n", "plt.ylim(-40, 0)\n", "plt.xlim(0, 50e9)\n", "plt.title(\"LFCN-2352+\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Compute Error and Plot Results" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "error_functions = [\n", " \"average_l1_norm\",\n", " \"average_l2_norm\",\n", " \"maximum_l1_norm\",\n", " \"average_normalized_l1_norm\",\n", "]\n", "\n", "for ef in error_functions:\n", " error = rf.network.s_error(ntwkA=ns[2], ntwkB=ns[1], error_function=ef)\n", " plt.plot(ns[2].frequency.f_scaled, 20 * np.log10(error), label=ef)\n", "\n", "plt.legend(fontsize=\"small\", ncols=2, loc=\"lower center\")\n", "plt.grid()\n", "plt.ylim(-50, 0)\n", "plt.xlim(0, 50000)\n", "plt.title(f\"Error Between {ns[2].name} and {ns[1].name}\", fontsize=\"small\")\n", "plt.xlabel(\"Frequency (MHz)\")" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 2 }